package myapp.services;

import java.util.ArrayList;

import android.util.Log;

import staticClass.XmppConnection;

import myapp.CTL.UserCTL;
import myapp.DAO.DataProvider;
import myapp.DTO.UserDTO;
import myapp.EnumAndConstans.Constants;

public class ChatServiceHelper {
	private UserCTL userCTL;
	
	public ChatServiceHelper(){
		DataProvider.chatBaseHost = Constants.CHAT_SERVER_URL+"/api/";
		//DataProvider.baseHost = "http://localhost:18628/api";
		userCTL = new UserCTL();
	}
	
	public String getMyName(String email, String pwd){
		return userCTL.getMyName(email, pwd);
	}
	
	public ArrayList<UserDTO> getAllFriends(String userEmail, String pwd){
		return userCTL.getAllFriends(userEmail, pwd);
	}
	
	public ArrayList<UserDTO> getOnlineFriends(){
		if (XmppConnection.isConnected())
			return userCTL.getOnlineFriends(XmppConnection.userEmail, XmppConnection.hashPwd);
		Log.e("ChatServiceHelper", "[getOnlineFriends] You 're not logged in!");
		return null;
	}
	
	public String RemoveFriend(String userEmail, String friendEmail){
		return userCTL.sendRemoveFriendShipRequest(userEmail, friendEmail);
	}
	
	public ArrayList<UserDTO> getAllRequesters(String userEmail, String pwd){
		return userCTL.getAllRequesters(userEmail, pwd);
	}
	
	public Boolean sendFriendRequest(String yourEmail, String yourFriendEmail){
		return userCTL.sendFriendRequest(yourEmail, yourFriendEmail);
	}
	
	public void sendAcceptFriendRequest(String receiverEmail, String requesterEmail){
		userCTL.sendAcceptFriendRequest(receiverEmail, requesterEmail);
	}
	
	public String addNewUser(String email, String name, String pwd){
		return userCTL.sendAddNewUserRequest(email, name, pwd);
	}
	
	public void UpdateUser(UserDTO info){
		userCTL.UpdateUser(info);
	}
}
